package jtk.project4.fleet.screen.invoice;

import java.sql.SQLException;

import nl.coderight.jazz.Controller;
import jtk.project4.fleet.FleetModel;
import jtk.project4.fleet.domain.Invoices;
import jtk.project4.fleet.event.InvoiceEvent;
import jtk.project4.fleet.event.InvoiceEvent.InvoiceEventType;
import jtk.project4.fleet.screen.inventory.InventoryController;
import jtk.project4.fleet.event.InvoiceEvent;
import jtk.project4.fleet.action.CancelInvoiceAction;
import jtk.project4.fleet.action.SaveInvoice;

public class InvoiceController extends Controller {
	private FleetModel fleetModel;
	private InvoiceView invoiceView;
	
/*	public void handleEvent(EquipmentEvent evt) {
*		Equipment equipment = fleetModel.getEquipment();
*		switch (evt.getType()) {
*		case SUBMIT:
*			//commit changes
*			System.out.println("CITY : " + simpleModel.getContact().getFirstname());
*			executeController(new View2Controller());
*			//simpleModel.insertOrUpdateContact(contact);
*			break;
*			
*		default:
*			propagateEvent(evt);
*			break;
*		}
*	}
*/	

	
	public void handleEvent(InvoiceEvent evt) throws SQLException {
		Invoices invoices = fleetModel.getInvoices();
		switch (evt.getType()) {
		case SAVE:
			fleetModel.insertInvoices(invoices);
			break;
		default:
		propagateEvent(evt);
		break;
		}
	}
	
	public void execute() {
		fleetModel = (FleetModel) getModel();
		invoiceView = new InvoiceView();
		setView(invoiceView);
		showView();
	}
}
